package ua.exchangeratesukraine.actions;

import ua.exchangeratesukraine.util.Constants;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBHelper extends SQLiteOpenHelper {

	private String	LOG_TAG		= getClass().getSimpleName();
	static String	dbName		= Constants.DB_NAME;
	private String	tableName	= "";
	private Context	context		= null;

	//	public SQLiteDatabase	db			= null;

	public DBHelper(Context context) {
		super(context, dbName, null, 1);
		this.context = context;
	}

	public void addTable(SQLiteDatabase db, String tableName) {
		Log.d(LOG_TAG, "---------- Create table |" + tableName + "|----------\nQuery:");
		String query = "create table if not exists " 
				+ tableName
				+ " (id integer primary key autoincrement," 
				+ " time integer," 
				+ " type string," 
				+ " value blob"
				+ ")"; 
		Log.d(LOG_TAG, query);
		db.execSQL(query);
		Log.d(LOG_TAG, "---------- Table " + tableName +  " created ----------");
	}

	@Override
	public void onCreate(SQLiteDatabase db) {}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
}
//db.rawQuery(SELECT _id, time from t1 where time between ? and ?, where); 